package com.hack.validator;


import jakarta.persistence.Entity;

import java.util.Objects;

/**
 * 验证规则类
 * 包含参数路径、参数类型、规则类型、规则配置、错误信息和应用ID
 *
 * @author hack
 * @version 1.0
 * @date 2025/07/11
 */
@Entity
public class ValidationRule {
    private Integer id;
    private String paramPath;
    private String paramType;
    private String ruleType;
    private String ruleConfig;
    private String errorMsg;
    private String appId;

    // Getters and Setters
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getParamPath() {
        return paramPath;
    }

    public void setParamPath(String paramPath) {
        this.paramPath = paramPath;
    }

    public String getParamType() {
        return paramType;
    }

    public void setParamType(String paramType) {
        this.paramType = paramType;
    }

    public String getRuleType() {
        return ruleType;
    }

    public void setRuleType(String ruleType) {
        this.ruleType = ruleType;
    }

    public String getRuleConfig() {
        return ruleConfig;
    }

    public void setRuleConfig(String ruleConfig) {
        this.ruleConfig = ruleConfig;
    }

    public String getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ValidationRule that = (ValidationRule) o;
        return Objects.equals(paramPath, that.paramPath) &&
                Objects.equals(ruleType, that.ruleType) &&
                Objects.equals(appId, that.appId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(paramPath, ruleType, appId);
    }
}
